package com.tech.koufu.ui.view;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

public class BaseSimpleFragment extends Fragment {
	
	private FragmentManager fragmentManager;
	/**
	 * 设置默认显示的fragment
	 */
	protected void setDefaultFragment(int content,Fragment target) {
		FragmentTransaction transaction = fragmentManager.beginTransaction(); 
		transaction.replace(content, target);
		transaction.commit();
	}

	/**
	 *切换fragment
	 * @param newFragment
	 */
	protected void replaceFragment(int content,Fragment newFragment) {
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		if (!newFragment.isAdded()) {
			transaction.replace(content, newFragment);
			transaction.commit();
		} else {
			transaction.show(newFragment);
		}
	}

}
